CSharpTest.Net
InstanceFactory<T> Constructor
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > InstanceFactory<T> Class : InstanceFactory<T> Constructor

instance

Glossary Item Box

Provide the instance of T

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal instance As T _
)
C# 
public InstanceFactory<T>( 
   T instance
)

Parameters

instance

Example

Library/Library.Test/TestFactories.cs

C#Copy Code
TestObject obj = new TestObject();
IFactory<TestObject> factory = new InstanceFactory<TestObject>(obj);
Assert.IsTrue(ReferenceEquals(obj, factory.Create()));
Assert.IsTrue(ReferenceEquals(factory.Create(), factory.Create()));
VB.NETCopy Code
Dim obj As New TestObject()
Dim factory As IFactory(Of TestObject) = New InstanceFactory(Of TestObject)(obj)
Assert.IsTrue(ReferenceEquals(obj, factory.Create()))
Assert.IsTrue(ReferenceEquals(factory.Create(), factory.Create()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys